/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.patpro.controladores;

import com.patpro.modelo.javabeans.Alumno;
import com.patpro.modelo.javabeans.AlumnoNota;
import com.patpro.modelo.javabeans.AsignacionAcademica;
import com.patpro.modelo.javabeans.Curso;
import com.patpro.modelo.javabeans.Profesor;
import com.patpro.modelo.javabeans.SemestreAcademico;
import com.patpro.modelo.servicios.AlumnoNotaService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

/**

 */
public class EliminaAlumnoCursoController extends AbstractController {

    private AlumnoNotaService servicio_alumnonota;

    public void setServicio_alumnonota(AlumnoNotaService servicio_alumnonota) {
        this.servicio_alumnonota = servicio_alumnonota;
    }

    public EliminaAlumnoCursoController() {
    }

    protected ModelAndView handleRequestInternal(
            HttpServletRequest request,HttpServletResponse response) throws Exception {
        ModelAndView mv = null;
        String id_semestre = request.getParameter("id_semestre");
        String id_curso = request.getParameter("id_curso");
        String id_profesor = request.getParameter("id_profesor");
        String id_alumno = request.getParameter("id_alumno");

        int resp = servicio_alumnonota.eliminarAlumnoNota(new AlumnoNota(
                                                                    new Curso(Integer.parseInt(id_curso)),
                                                                    new SemestreAcademico(Integer.parseInt(id_semestre)),
                                                                    new Profesor(Integer.parseInt(id_profesor)),
                                                                    new Alumno(Integer.parseInt(id_alumno))
                                                        ));
        if(resp > 0)
            mv = new ModelAndView("exito");
        else
            mv = new ModelAndView("error");
        mv.addObject("controlador", "adminAlumnoCurso");
        return mv;
    }
}
